package com.hy.ssm.biz.impl;

import com.hy.ssm.bean.TypeInfo;
import com.hy.ssm.biz.ITypeInfoBiz;

import com.hy.ssm.mapper.ITypeInfoMapper;
import com.hy.ssm.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: HuYang
 * @Date: 2022/11/10 - 11 - 10 - 20:17
 * @Description: com.yc.snack.biz.impl
 * @version: 1.0
 */
@Service
public class TypeInfoBizImpl implements ITypeInfoBiz {

    @Autowired
    private ITypeInfoMapper typeInfoMapper;

    @Override
    public int add(TypeInfo tf) {
        if (StringUtil.checkNull(tf.getTname())){
            return -1;
        }
        return typeInfoMapper.add(tf);
    }

    @Override
    public List<TypeInfo> finds() {

        return typeInfoMapper.finds();
    }

    @Override
    public Map<String, Object> findByPage(Map<String,Object> map) {
        List<TypeInfo> list = typeInfoMapper.findByPage(StringUtil.findByPageTable(map));
        Map<String,Object> result = new HashMap<>();
        if (list == null || list.isEmpty()){
            result.put("code","600");
            result.put("msg","暂无数据...");
            return result;
        }
        result.put("code",0);
        result.put("data",list);
        result.put("count",typeInfoMapper.getTotal());
        return result;
    }
}
